{* FILTERS *}

{literal}
<script language="javascript">
	function addfilter(field,value) {
		var forma = document.getElementById("list_form");
		var f = document.getElementById(field);
		f.value=value;		
		forma.submit();
	}
	function updateRequest(id,action) {
		var forma = document.getElementById("list_form");
		forma.op.value=action;
		forma.id.value=id;
		forma.submit();
	}
	function startEdit(id,name,lang) {
		var forma = document.getElementById("team_form");
		forma.op.value='edit';
		forma.id.value=id;
		forma.name.value=name;
		forma.lang.value=lang;
		document.getElementById("edit_form").style.display = '';
		document.getElementById("add_form").style.display = 'none';
	}
	function cancelEdit() {
		var forma = document.getElementById("team_form");
		forma.op.value='add';
		forma.name.value='';
		forma.lang.value='';
		document.getElementById("edit_form").style.display = 'none';
		document.getElementById("add_form").style.display = '';
	}
</script>
{/literal}

<script language="javascript">

	function deleteTeam() {ldelim}
		if (confirm('{$lang.confirmdelete}')) {ldelim} 
			updateRequest('','remove')
		{rdelim}	
	{rdelim}
					
</script>

<center>
<form method="post" id="team_form">
	<input type="hidden" name="flowid" id="flowid" value="{$flowid}">
	<input type="hidden" name="action" id="action" value="teamadmin">
	<input type="hidden" name="op" id="op" value="add">
	<input type="hidden" name="id" id="id" value="">	
	 <table width="100%" cellpadding="0" cellspacing="0">
	   <tr>
		 <td>&nbsp;{$lang.name}</td>
		 <td><input type="text" size="20" maxlength="20" name="name" id="name" class="txt"></td>
		</tr>
	   <tr>
		 <td>&nbsp;{$lang.lang}</td>
		 <td>
			<select name="lang" id="lang" class="txt">
				<optgroup label="{$lang.unusedlang}">
				{foreach from=$flanglist item=lrow}
					<option value="{$lrow->id}">{$lrow->id}</option>
				{/foreach}
				<optgroup label="{$lang.usedlang}">
				{foreach from=$ulanglist item=lrow}
					<option value="{$lrow->id}">{$lrow->id}</option>
				{/foreach}
			</select>			 
		</tr>
		</tr>
			 <td align="right" colspan="2">
			 <div id="add_form">
			 {include file="button.tpl" name=$lang.new action="processForm('team_form')"}
			 </div>
			 <div id="edit_form" style="display: none;">
			 {include file="button.tpl" name=$lang.ok action="processForm('team_form')"}
			 &nbsp;{include file="button.tpl" name=$lang.cancel action="cancelEdit()"}
			 </div>
			 </td>
	   </tr>
	 </table>	
</form>
</center>


<center>
<form method="post" id="list_form">
	<input type="hidden" name="flowid" id="flowid" value="{$flowid}">
	<input type="hidden" name="action" id="action" value="teamadmin">
	<input type="hidden" name="op" id="op" value="">	
	<input type="hidden" name="id" id="id" value="">

<table align="center" width="100%" border="0" cellpadding="0" cellspacing="0">

	<thead>
		<tr>
			<th>{$lang.team}</th>
			<th>{$lang.lang}</th>
			<th>{$lang.status}</th>
			<th>&nbsp;</th>
			<th>
				<img src="images/arrowdown.png" alt="" width="18" height="18" class="link" onclick="checkAll('teamid[]')">
				<img src="images/arrowup.png" alt="" width="18" height="18" class="link" onclick="uncheckAll('teamid[]')">
			</th>
		</tr>
	</thead>

	{* TABLE BODY - DYNAMIC *}
	<tbody>
		{assign var="rowclass" value="uneven"}
		{foreach from=$list item=row}
			{eval var=$row->status assign="stid"}
			<tr class="{$rowclass}" {if $stid neq 'ACTIVE'} style="font-style: italic" {/if}>
				<td>{$row->name}</td>
				<td>{$row->lang}</td>				
				<td>{$lang.$stid}</td>
				<td>
					<span onclick="startEdit('{$row->id}','{$row->name}','{$row->lang}')" class="link">{$lang.edit}</span>
				</td>
				<td align="center">
					<input type="checkbox" class="txt" name="teamid[]" id="teamid[]" value="{$row->id}" />
				</td> 
			</tr>
			{if $rowclass eq 'even'}
				{assign var="rowclass" value="uneven"}
			{else}
				{assign var="rowclass" value="even"}
			{/if}
		{/foreach}

	</tbody>

	<tfoot>
		<tr>
			<th colspan="5">
				{include file="button.tpl" name=$lang.deactivate action="updateRequest('','deact')"}
				{include file="button.tpl" name=$lang.activate action="updateRequest('','act')"}
				{include file="button.tpl" name=$lang.remove action="deleteTeam()"}
			</th>
		</tr>
	</tfoot>
</table>
</form>
<center>